package com.example.demo.moduel.controller;

import com.example.demo.moduel.entity.User;
import com.example.demo.moduel.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {

       @Autowired
       private UserRepository userRepository;

       @RequestMapping("api/user/getUser")
       @ResponseBody
       public User getUser() {
              /*此处使用getOne()方法会报错*/
              return userRepository.findOne(4L);
       }
}
